/**
 * 
 */
package com.elite.groovy.callback

import groovy.json.* //导入grooby的json解析api包
import java.util.Map;
import com.elite.groovy.util.EliteBean
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.elite.groovy.util.Util;
import net.sf.json.JSONObject;
import net.sf.json.JSONArray;

 
public class OAUtils implements ServiceBackInvoke{
	private static final Log log=LogFactory.getLog(OAUtils.class);
	private String charset = "utf-8"; //设置字符集
	private int timeout = 100000; //设置请求超时时间
	private int enableSSLflag = 1;	
	public String doCallBack(EliteBean eliteBean,HttpServletRequest request,HttpServletResponse response){
		
		//获取入参
		def workorderid=request.getParameter("workorderid");
		def handletype=request.getParameter("handletype");
		def mapid=request.getParameter("mapid");
		def reopen=request.getParameter("reopen");
		def sname=request.getParameter("sname");
		def com=request.getParameter("com");
		log.debug("------------------com内容-----------"+com);
		//参数校验
		JSONObject resulterror = new JSONObject();
		if(workorderid.equals("") || workorderid==null){
			resulterror.put("code", "-1");
			resulterror.put("msg", "工单编号不能为空！");
			resulterror.put("data", "");			
			return  resulterror;
		}else if(handletype.equals("") || handletype== null){
			resulterror.put("code", "-1");		
			resulterror.put("msg", "处理类型不能为空");
			resulterror.put("data", "");
			return  resulterror;
		}else if((mapid.equals("") || mapid== null) && handletype=="insert"){
			resulterror.put("code", "-1");		
			resulterror.put("msg", "工单mapid不能为空");
			resulterror.put("data", "");
			return  resulterror;
		}
		
		if(handletype=="insert" && mapid=="DHBZGD"){	 //标准工单提交OA
			BZGDinsert(workorderid,eliteBean,reopen);
		}else if(handletype=="insert" && mapid=="Q5NCDR"){	 //投诉工单提交OA
			TSGDinsert(workorderid,eliteBean,reopen);
		}else if(handletype=="insert" && mapid=="3EN351"){	 //准投诉工单提交OA
			ZTSGDinsert(workorderid,eliteBean,reopen);
		}else if(handletype=="insert" && mapid=="BFIFE6"){	 //报案工单提交OA
			BAGDinsert(workorderid,eliteBean,reopen);
		}else if(handletype=="select"){	 //查询处理历史
			selectOA(eliteBean,workorderid);
		}else if(handletype=="reminder"){	 //催单
			OAurge(workorderid,eliteBean,reopen,sname,com);
		}else if(handletype=="zjbz"){	 //催单
			zjbz(workorderid,eliteBean,reopen,sname,com);
		}

 
	}
		
		//标准工单的查询
	private JSONObject BZGDinsert(String workorderid,EliteBean eliteBean,String reopen){
			JSONObject result = new JSONObject();
		def smap = eliteBean.chaxun_sql("select o.workorderid as MsgID,case when o.MAP_ID='DHBZGD' then '4195' when o.MAP_ID='BFIFE6' then '4193' when o.MAP_ID='Q5NCDR' then '4191' else '' end as FlowType,TC.ORDER_TITLE as MsgTitle,case when o.MAP_ID='DHBZGD' then '0' when o.MAP_ID='BFIFE6' then '1' when o.MAP_ID='Q5NCDR' then '2' else '' end as OrderType,o.WORKORDERTYPE as ChildType,c.CUSTOMERNAME as UserName,c.GENDER as sex,c.E_MAIL as UserEmail,o.CALLTEL as PhoneNum,case when o.WORKORDERTYPE='注销报案申请' then TC.ORDER_DESCRIPTION||'\n销案原因:'||tc.CANCELLATION||'\n身份证号码:'||tc.CARDNO||'\n是否已查勘现场:'||tc.ISSURVEY||'\n其他原因:'||tc.OTHERS||'\n备注:'||o.COMMENTS when o.WORKORDERTYPE='增值服务' then TC.ORDER_DESCRIPTION||'\n救援省市区:'||tc.PROVINCE||tc.CITY||tc.AREA||'\n服务项目:'||tc.PROJECT||'\n详细位置:'||tc.ADDRESS||'\n服务类型:'||tc.SERVERTYPE||'\n备注:'||o.COMMENTS else TC.ORDER_DESCRIPTION||'\n备注:'||o.COMMENTS  end as Message,o.CREATEDDATE as InputTime,sysdate as CreateTime,case when o.MAP_ID='DHBZGD' then TC.ORDERLEVEL else '' end as orderLevel,o.ORGANIZA as orderDepartID,o.EXPIREDDATE as dealLimitedDate,s.agent_id as AgnetId,o.POLICYNO as PolicyNo,o.CARNO as LicenseNo,o.REPORTNO as ReportNo,o.COVERAGE_NAME as InsuranceType,'' as dangerTime,'' as dangerSite,'' as reportedLossMoney,'' as impairedReason,'' as accidentDescription,'' as ComplainType,'' as AccusedMan,'' as IfVisit,'' as AccuseType,'' as CustRequest,'' as Figure,'0' as MsgState,'0' as SendState,o.ORGANIZANAME as COMNAME,o.CALLSTARTTIME as callTime,c.mobile as callTel,'' as callZip,c.ADDRESS as callAddress,o.INSURED as insured,'' as unitName,o.insured_relation as relationtype,'' as accuseItem,o.callby as prplregistlinkername,'' as prplthirdpartylicenseno,'' as firstsiteflag,'' as tsdrivername,''as tsdriverphone,'' as Flag1 from OBJECTIVE o left join tabcorder_non_case tc on tc.RELATION_ID=o.OBJECTIVE_GUID left join customer c on c.customer_guid=o.customer_guid left join staff s on s.staff_id=o.createdby where o.MAP_ID='DHBZGD' and o.OBJECTIVESTATUS='OPEN' and o.WORKORDERID='"+workorderid+"'","dataSource");
		if(smap.size()==0) {
				result.put("code", "-1");
				result.put("msg", "未找到对应的工单");
				result.put("data", "");
				return result;
		};
		
		def resultoa=submitOA(eliteBean,smap,reopen);

		if(resultoa!="1"){
			result.put("code", "1");
			result.put("msg", "提交失败");
			result.put("data", "");
			return result;
		}
			result.put("code", "1");
			result.put("msg", "已提交成功");
			result.put("data", "");
			return result;
		
	}

	//投诉工单的查询
	private JSONObject TSGDinsert(String workorderid,EliteBean eliteBean,String reopen){
			JSONObject result = new JSONObject();
		def smap = eliteBean.chaxun_sql("select o.workorderid as MsgID,case when o.MAP_ID='DHBZGD' then '4195' when o.MAP_ID='BFIFE6' then '4193' when o.MAP_ID='Q5NCDR' then '4191' else '' end as FlowType,TC.order_title as MsgTitle,case when o.MAP_ID='DHBZGD' then '0' when o.MAP_ID='BFIFE6' then '1' when o.MAP_ID='Q5NCDR' then '2' else '' end as OrderType,o.WORKORDERTYPE as ChildType,c.CUSTOMERNAME as UserName,c.GENDER as sex,c.E_MAIL as UserEmail,o.CALLTEL as PhoneNum,TC.accuse_content||'\n备注:'||o.COMMENTS as Message,o.CREATEDDATE as InputTime,sysdate as CreateTime,'' as orderLevel,o.ORGANIZA as orderDepartID,o.EXPIREDDATE as dealLimitedDate,s.agent_id as AgnetId,o.POLICYNO as PolicyNo,o.CARNO as LicenseNo,o.REPORTNO as ReportNo,o.COVERAGE_NAME as InsuranceType,'' as dangerTime,'' as dangerSite,'' as reportedLossMoney,'' as impairedReason,'' as accidentDescription,TC.accusessresource as ComplainType,TC.accused_man as AccusedMan,TC.CALLBACK_IF  as IfVisit,'' as AccuseType,TC.CUSTOMER_CLAIM as CustRequest,o.ts_customertype as Figure,'0' as MsgState,'0' as SendState,o.ORGANIZANAME as COMNAME,o.CALLSTARTTIME as callTime,c.mobile as callTel,'' as callZip,c.ADDRESS as callAddress,o.INSURED as insured,'' as unitName,'' as accuseItem,o.insured_relation as relationtype,o.callby as prplregistlinkername,'' as prplthirdpartylicenseno,'' as firstsiteflag,'' as tsdrivername,''as tsdriverphone,'' as Flag1 from OBJECTIVE o left join tabcorder_accuse tc on tc.RELATION_ID=o.OBJECTIVE_GUID left join customer c on c.customer_guid=o.customer_guid left join staff s on s.staff_id=o.createdby where o.MAP_ID='Q5NCDR' and o.OBJECTIVESTATUS='OPEN' and o.WORKORDERID='"+workorderid+"'","dataSource");
		
		if(smap.size()==0) {
				result.put("code", "-1");
				result.put("msg", "未找到对应的工单");
				result.put("data", "");
				return result;
		};
		
		def resultoa=submitOA(eliteBean,smap,reopen);

		if(resultoa!="1"){
			result.put("code", "1");
			result.put("msg", "提交失败");
			result.put("data", "");
			return result;
		}
			result.put("code", "1");
			result.put("msg", "已提交成功");
			result.put("data", "");
			return result;
		
	}
	
	//投诉工单的查询
	private JSONObject ZTSGDinsert(String workorderid,EliteBean eliteBean,String reopen){
			JSONObject result = new JSONObject();
		def smap = eliteBean.chaxun_sql("select o.workorderid as MsgID,case when o.MAP_ID='DHBZGD' then '4195' when o.MAP_ID='BFIFE6' then '4193' when o.MAP_ID='Q5NCDR' then '4191' when o.MAP_ID='3EN351' then '4191' else '' end as FlowType,'准投诉'||o.workorderid as MsgTitle,case when o.MAP_ID='DHBZGD' then '0' when o.MAP_ID='BFIFE6' then '1' when o.MAP_ID='Q5NCDR' then '2' when o.MAP_ID='3EN351' then '2' else '' end as OrderType,o.WORKORDERTYPE as ChildType,c.CUSTOMERNAME as UserName,c.GENDER as sex,c.E_MAIL as UserEmail,o.CALLTEL as PhoneNum,TC.content||'\n备注:'||o.COMMENTS as Message,o.CREATEDDATE as InputTime,sysdate as CreateTime,'' as orderLevel,o.ORGANIZA as orderDepartID,o.EXPIREDDATE as dealLimitedDate,s.agent_id as AgnetId,o.POLICYNO as PolicyNo,o.CARNO as LicenseNo,o.REPORTNO as ReportNo,o.COVERAGE_NAME as InsuranceType,'' as dangerTime,'' as dangerSite,'' as reportedLossMoney,'' as impairedReason,'' as accidentDescription,'' as ComplainType,'' as AccusedMan,TC.if_visit  as IfVisit,'' as AccuseType,'' as CustRequest,o.ts_customertype as Figure,'0' as MsgState,'0' as SendState,o.ORGANIZANAME as COMNAME,o.CALLSTARTTIME as callTime,c.mobile as callTel,'' as callZip,c.ADDRESS as callAddress,o.INSURED as insured,'' as unitName,'' as accuseItem,o.insured_relation as relationtype,o.callby as prplregistlinkername,'' as prplthirdpartylicenseno,'' as firstsiteflag,'' as tsdrivername,''as tsdriverphone,'' as Flag1 from OBJECTIVE o left join tabcorder_zts tc on tc.RELATION_ID=o.OBJECTIVE_GUID  left join customer c on c.customer_guid=o.customer_guid  left join staff s on s.staff_id=o.createdby where o.MAP_ID='3EN351' and o.OBJECTIVESTATUS='OPEN' and o.WORKORDERID='"+workorderid+"'","dataSource");
		
		if(smap.size()==0) {
				result.put("code", "-1");
				result.put("msg", "未找到对应的工单");
				result.put("data", "");
				return result;
		};
		
		def resultoa=submitOA(eliteBean,smap,reopen);

		if(resultoa!="1"){
			result.put("code", "1");
			result.put("msg", "提交失败");
			result.put("data", "");
			return result;
		}
			result.put("code", "1");
			result.put("msg", "已提交成功");
			result.put("data", "");
			return result;
		
	}
	
	//报案工单的查询
	private JSONObject BAGDinsert(String workorderid,EliteBean eliteBean,String reopen){
			JSONObject result = new JSONObject();
		def smap = eliteBean.chaxun_sql("select o.workorderid as MsgID,case when o.MAP_ID='DHBZGD' then '4195' when o.MAP_ID='BFIFE6' then '4193' when o.MAP_ID='Q5NCDR' then '4191' else '' end as FlowType,TC.report_title as MsgTitle,case when o.MAP_ID='DHBZGD' then '0' when o.MAP_ID='BFIFE6' then '1' when o.MAP_ID='Q5NCDR' then '2' else '' end as OrderType,case when o.order_report_type = 'RCBA' then '车险报案' when o.order_report_type = 'RFBA' then '非车险报案'  end as ChildType,c.CUSTOMERNAME as UserName,c.GENDER as sex,c.E_MAIL as UserEmail,o.CALLTEL as PhoneNum,o.COMMENTS as Message,o.CREATEDDATE as InputTime,sysdate as CreateTime,'' as orderLevel,o.ORGANIZA as orderDepartID,o.EXPIREDDATE as dealLimitedDate,s.agent_id as AgnetId,o.POLICYNO as PolicyNo,o.CARNO as LicenseNo,o.REPORTNO as ReportNo,o.COVERAGE_NAME as InsuranceType,TC.danger_time as dangerTime,TC.DANGER_SITE_PROVINCE_LABEL||TC.DANGER_SITE_CITY_LABEL||tc.DANGER_SITE_AREA_LABEL||TC.address_detailed as dangerSite,TC.reported_loss_money as reportedLossMoney,case when  o.order_report_type = 'RCBA'  then TC.accident_reason else rfba_accident_reason end as impairedReason,TC.accident_experience as accidentDescription,'' as ComplainType,'' as AccusedMan,'' as IfVisit,'' as AccuseType,'' as CustRequest,'' as Figure,'0' as MsgState,'0' as SendState,o.ORGANIZANAME as COMNAME,o.CALLSTARTTIME as callTime,c.mobile as callTel,'' as callZip,c.ADDRESS as callAddress,o.INSURED as insured,'' as unitName,'' as accuseItem,o.insured_relation as relationtype,o.callby as prplregistlinkername,TC.prplthirdpartylicenseno as prplthirdpartylicenseno,TC.firstsiteflag as firstsiteflag,TC.driver as tsdrivername,''as tsdriverphone,'' as Flag1 from OBJECTIVE o left join tabcorder_report_case tc on tc.RELATION_ID=o.OBJECTIVE_GUID left join customer c on c.customer_guid=o.customer_guid  left join staff s on s.staff_id=o.createdby  where o.MAP_ID='BFIFE6' and o.OBJECTIVESTATUS='OPEN' and o.WORKORDERID='"+workorderid+"'","dataSource");
		if(smap.size()==0) {
				result.put("code", "-1");
				result.put("msg", "未找到对应的工单");
				result.put("data", "");
				return result;
		};
		
		def resultoa=submitOA(eliteBean,smap,reopen);

		if(resultoa!="1"){
			result.put("code", "1");
			result.put("msg", "提交失败");
			result.put("data", "");
			return result;
		}
			result.put("code", "1");
			result.put("msg", "已提交成功");
			result.put("data", "");
			return result;
		
	}

		//提交OA方法
	private String submitOA(EliteBean eliteBean,ArrayList smap,String reopen){
			log.debug("客户系统数组-------------"+smap);
			def oaflag;
			try{
				oaflag=eliteBean.update("insert into EXCHANGE_RECEIVE(ID,MsgID,FlowType,MsgTitle,OrderType,ChildType,UserName,Sex,UserEmail,PhoneNum,Message,InputTime,CreateTime,orderLevel,orderDepartID,dealLimitedDate,AgnetId,PolicyNo,LicenseNo,ReportNo,InsuranceType,dangerTime,dangerSite,reportedLossMoney,impairedReason,accidentDescription,ComplainType,AccusedMan,IfVisit,AccuseType,CustRequest,Figure,MsgState,SendState,COMNAME,callTime,callTel,callZip,callAddress,insured,unitName,accuseItem,relationtype,prplregistlinkername,prplthirdpartylicenseno,firstsiteflag,tsdrivername,tsdriverphone,Flag1)values(SEQCCEXCHANGERECEIVE.nextval,DECODE('"+smap[0].getAt("MsgID")+"','null','','"+smap[0].getAt("MsgID")+reopen+"'),DECODE('"+smap[0].getAt("FlowType")+"','null','','"+smap[0].getAt("FlowType")+"'),DECODE('"+smap[0].getAt("MsgTitle")+"','null','','"+smap[0].getAt("MsgTitle")+"'),DECODE('"+smap[0].getAt("OrderType")+"','null','','"+smap[0].getAt("OrderType")+"'),DECODE('"+smap[0].getAt("ChildType")+"','null','','"+smap[0].getAt("ChildType")+"'),DECODE('"+smap[0].getAt("UserName")+"','null','','"+smap[0].getAt("UserName")+"'),DECODE('"+smap[0].getAt("Sex")+"','null','','"+smap[0].getAt("Sex")+"'),DECODE('"+smap[0].getAt("UserEmail")+"','null','','"+smap[0].getAt("UserEmail")+"'),DECODE('"+smap[0].getAt("PhoneNum")+"','null','','"+smap[0].getAt("PhoneNum")+"'),DECODE('"+smap[0].getAt("Message")+"','null','','"+smap[0].getAt("Message")+"'),to_date(DECODE('"+smap[0].getAt("InputTime")+"','null','',SUBSTR('"+smap[0].getAt("InputTime")+"', 1, 18)),'yyyy-mm-dd hh24:mi:ss'),to_date(DECODE('"+smap[0].getAt("CreateTime")+"','null','',SUBSTR('"+smap[0].getAt("CreateTime")+"', 1, 18)),'yyyy-mm-dd hh24:mi:ss'),DECODE('"+smap[0].getAt("orderLevel")+"','null','','"+smap[0].getAt("orderLevel")+"'),DECODE('"+smap[0].getAt("orderDepartID")+"','null','','"+smap[0].getAt("orderDepartID")+"'),DECODE('"+smap[0].getAt("dealLimitedDate")+"','null','','"+smap[0].getAt("dealLimitedDate")+"'),DECODE('"+smap[0].getAt("AgnetId")+"','null','','"+smap[0].getAt("AgnetId")+"'),DECODE('"+smap[0].getAt("PolicyNo")+"','null','','"+smap[0].getAt("PolicyNo")+"'),DECODE('"+smap[0].getAt("LicenseNo")+"','null','','"+smap[0].getAt("LicenseNo")+"'),DECODE('"+smap[0].getAt("ReportNo")+"','null','','"+smap[0].getAt("ReportNo")+"'),DECODE('"+smap[0].getAt("InsuranceType")+"','null','','"+smap[0].getAt("InsuranceType")+"'),to_date(DECODE('"+smap[0].getAt("dangerTime")+"','null','',SUBSTR('"+smap[0].getAt("dangerTime")+"', 1, 18)),'yyyy-mm-dd hh24:mi:ss'),DECODE('"+smap[0].getAt("dangerSite")+"','null','','"+smap[0].getAt("dangerSite")+"'),DECODE('"+smap[0].getAt("reportedLossMoney")+"','null','','"+smap[0].getAt("reportedLossMoney")+"'),DECODE('"+smap[0].getAt("impairedReason")+"','null','','"+smap[0].getAt("impairedReason")+"'),DECODE('"+smap[0].getAt("accidentDescription")+"','null','','"+smap[0].getAt("accidentDescription")+"'),DECODE('"+smap[0].getAt("ComplainType")+"','null','','"+smap[0].getAt("ComplainType")+"'),DECODE('"+smap[0].getAt("AccusedMan")+"','null','','"+smap[0].getAt("AccusedMan")+"'),DECODE('"+smap[0].getAt("IfVisit")+"','null','','"+smap[0].getAt("IfVisit")+"'),DECODE('"+smap[0].getAt("AccuseType")+"','null','','"+smap[0].getAt("AccuseType")+"'),DECODE('"+smap[0].getAt("CustRequest")+"','null','','"+smap[0].getAt("CustRequest")+"'),DECODE('"+smap[0].getAt("Figure")+"','null','','"+smap[0].getAt("Figure")+"'),DECODE('"+smap[0].getAt("MsgState")+"','null','','"+smap[0].getAt("MsgState")+"'),DECODE('"+smap[0].getAt("SendState")+"','null','','"+smap[0].getAt("SendState")+"'),DECODE('"+smap[0].getAt("COMNAME")+"','null','','"+smap[0].getAt("COMNAME")+"'),to_date(DECODE('"+smap[0].getAt("callTime")+"','null','',SUBSTR('"+smap[0].getAt("callTime")+"', 1, 18)),'yyyy-mm-dd hh24:mi:ss'),DECODE('"+smap[0].getAt("callTel")+"','null','','"+smap[0].getAt("callTel")+"'),DECODE('"+smap[0].getAt("callZip")+"','null','','"+smap[0].getAt("callZip")+"'),DECODE('"+smap[0].getAt("callAddress")+"','null','','"+smap[0].getAt("callAddress")+"'),DECODE('"+smap[0].getAt("insured")+"','null','','"+smap[0].getAt("insured")+"'),DECODE('"+smap[0].getAt("unitName")+"','null','','"+smap[0].getAt("unitName")+"'),DECODE('"+smap[0].getAt("accuseItem")+"','null','','"+smap[0].getAt("accuseItem")+"'),DECODE('"+smap[0].getAt("relationtype")+"','null','','"+smap[0].getAt("relationtype")+"'),DECODE('"+smap[0].getAt("prplregistlinkername")+"','null','','"+smap[0].getAt("prplregistlinkername")+"'),DECODE('"+smap[0].getAt("prplthirdpartylicenseno")+"','null','','"+smap[0].getAt("prplthirdpartylicenseno")+"'),DECODE('"+smap[0].getAt("firstsiteflag")+"','null','','"+smap[0].getAt("firstsiteflag")+"'),DECODE('"+smap[0].getAt("tsdrivername")+"','null','','"+smap[0].getAt("tsdrivername")+"'),DECODE('"+smap[0].getAt("tsdriverphone")+"','null','','"+smap[0].getAt("tsdriverphone")+"'),DECODE('"+smap[0].getAt("Flag1")+"','null','','"+smap[0].getAt("Flag1")+"'))","dataSource-oa");	
							
				log.debug("---------------insert状态-------------"+oaflag);
				return oaflag;
			}catch(Exception e){
				oaflag=-1;
				log.debug(e);
				return oaflag;
			}

	}	
		
		//OA处理历史查询
	private JSONObject selectOA(EliteBean eliteBean,String workorderid){
		JSONObject result = new JSONObject();
		JSONArray data = new JSONArray();
		JSONObject sarr = new JSONObject();
		try{
				def oahandlelist = eliteBean.chaxun_sql("select  t.Dealer as Dealer,t.Flowname as Flowname,DECODE(to_char(t.AcceDealTime, 'yyyy-MM-dd hh24:mi:ss'),'','null',to_char(t.AcceDealTime, 'yyyy-MM-dd hh24:mi:ss')) as AcceDealTime, DECODE(to_char(t.LastDealTime, 'yyyy-MM-dd hh24:mi:ss'),'','null',to_char(t.LastDealTime, 'yyyy-MM-dd hh24:mi:ss')) as  LastDealTime, DECODE(REPLACE(REPLACE(t.IDEA,CHR(13),''),CHR(10),''),'','null',REPLACE(REPLACE(t.IDEA,CHR(13),''),CHR(10),'')) as Idea,t.State as State  from EXCHANGE_FLOW t   where t.RecordID like '"+workorderid+"%' order by AcceDealTime desc","dataSource-oa");
				
		log.debug("---------------OA处理历史-------------"+oahandlelist);
		if(oahandlelist.size()==0){
			result.put("msg", "未查询到OA处理历史");
			result.put("code", "-1");
			result.put("data", "");
			return result;
		}		
		for(int i=0;i<oahandlelist.size();i++){
			sarr.put("Dealer",oahandlelist[i].getAt("Dealer"));
			sarr.put("Flowname",oahandlelist[i].getAt("Flowname"));
			sarr.put("AcceDealTime",oahandlelist[i].getAt("AcceDealTime"));
			sarr.put("LastDealTime",oahandlelist[i].getAt("LastDealTime"));
			sarr.put("Idea",oahandlelist[i].getAt("Idea"));
			sarr.put("State",oahandlelist[i].getAt("State"));
			data.add(sarr);
		}		
		result.put("msg", "调用成功");
		result.put("code", "1");
		result.put("data", data);
		return result;
		
		}catch(Exception e){
			log.debug(e);
			result.put("msg", "查询OA处理历史异常");
			result.put("code", "-1");
			result.put("data", "");
			return result;
		}


	}
	

	private JSONObject OAurge(String workorderid,EliteBean eliteBean,String reopen,String sname,String com){
		JSONObject result = new JSONObject();		
		def type="yyyy-MM-dd HH:mm:ss";
		def datetime=Util.getNowString(type);
			try{
					log.debug("---------------催办内容-------------"+com);
				def oaflagcd=eliteBean.update("update EXCHANGE_RECEIVE s set  s.CCNOTE=s.CCNOTE||'"+"催办人:"+sname+"\n催办时间:"+datetime+"\n催办内容:"+com+"\n' ,s.ORDERTYPE = '4' where s.MSGID='"+workorderid+reopen+"'","dataSource-oa");
				
				//s.FLAG1 = '"+workorderid+"',s.FLAG3 = '"+"催办人:"+sname+"\n创建时间:"+datetime+"\n催办内容:"+com+"'
				log.debug("---------------催办OA-------------aaa"+oaflagcd);
				
				if(oaflagcd<1){
					result.put("code", "-1");
					result.put("msg", "催办失败");
					result.put("data", "");
					return result;
				}
					result.put("code", "1");
					result.put("msg", "已催办");
					result.put("data", "");
					return result;
			}catch(Exception e){
					log.debug(e);
					result.put("msg", "OA数据处理异常");
					result.put("code", "-1");
					result.put("data", "");
					return result;
			}
		
	}
	
		private JSONObject zjbz(String workorderid,EliteBean eliteBean,String reopen,String sname,String com){
		JSONObject result = new JSONObject();		
		def type="yyyy-MM-dd HH:mm:ss";
		def datetime=Util.getNowString(type);
			try{
					log.debug("---------------zjbz内容-------------"+com);
				def oaflagcd=eliteBean.update("update EXCHANGE_RECEIVE s set  s.CCNOTE=s.CCNOTE||'"+"备注人:"+sname+"\n备注时间:"+datetime+"\n备注内容:"+com+"\n'  where s.MSGID='"+workorderid+reopen+"'","dataSource-oa");
				
				log.debug("---------------zjbzOA-------------aaa"+oaflagcd);
				
				if(oaflagcd<1){
					result.put("code", "-1");
					result.put("msg", "备注失败");
					result.put("data", "");
					return result;
				}
					result.put("code", "1");
					result.put("msg", "已备注");
					result.put("data", "");
					return result;
			}catch(Exception e){
					log.debug(e);
					result.put("msg", "OA数据处理异常");
					result.put("code", "-1");
					result.put("data", "");
					return result;
			}
		
	}
	
	
	
	
	
	
	
}
